package checkers3d.presentation;

import java.awt.Point;

/**
 * A generic visible GUI component for any drawing primitive.
 *
 * @author      Ruben Acuna
 */
public class GUIPrimitive implements IDrawable
{
    /**
    * The position of this component within a GUIContainer or window space.
    */
    private Point position;
    
    /**
    * The IRenderResource that defines how the component looks.
    */
    private IRenderResource resource;

    /**
    * Class constructor that uses a preexisting IResourceBitmap draw data and
    * positions it at the coordinates passed.
    *
    * @param resource   A IRenderResource that will be used for rendering.
    * @param position   The position of this object relative to its container.
    */
    public GUIPrimitive(IRenderResource resource, Point position)
    {
        setDrawPosition(position);
        setRenderResource(resource);
    }

    /**
    * Returns the position of the IRenderResource.
    *
    * @return The position of this IRenderResource.
    * @see IDrawable
    */
    public Point getDrawPosition()
    {
        return position;
    }

    /**
    * Sets the current the position of the IRenderResource.
    *
    * @param  position The new position of this IRenderResource.
    * @see IDrawable
    */
    public void setDrawPosition(Point position)
    {
        this.position = position;
    }

    /**
    * Returns the IRenderResource of the IRenderResource.
    *
    * @return The IRenderResource of this IRenderResource.
    * @see IDrawable
    */
    public IRenderResource getRenderResource()
    {
        return resource;
    }

    /**
    * Sets the current the IRenderResource of the IRenderResource.
    *
    * @param  resource The new IRenderResource of this IRenderResource.
    */
    public void setRenderResource(IRenderResource resource)
    {
        this.resource = resource;
    }

    /**
    * Returns a string representation of the GUIPrimitive which contains
    * information about its IRenderResource.
    *
    * @return       A string representation of this GUIPrimitive.
    */
    @Override
    public String toString()
    {
        return getClass().getName() + " -> " + resource.toString();
    }
}